//
//  MingXiVC.m
//  夺宝吧
//
//  Created by xiaocai on 15/7/23.
//  Copyright (c) 2015年 FangYuan. All rights reserved.
//

#import "MingXiVC.h"
#import "ZhuangHuView.h"
#import "MingXiTab.h"
@interface MingXiVC ()<UIScrollViewDelegate>
{
    ZhuangHuView *_zhanghuView;
    UIScrollView *_s;
}
@end

@implementation MingXiVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = QBB_GRAY_COLOR;
    // Do any additional setup after loading the view.
    [self loadCustomNaviBar];
    _zhanghuView = [[[NSBundle mainBundle]loadNibNamed:@"ZhuangHuView" owner:self options:nil]lastObject];
    _zhanghuView.father = self;
    _zhanghuView.frame = CGRectMake(0, 64, WYMWITH, _zhanghuView.frame.size.height);
    [self.view addSubview:_zhanghuView];
    [self loadSubView];
}
//加载子界面
- (void)loadSubView
{
    _s = [[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_zhanghuView.frame), WYMWITH, WYMHEIGHT - CGRectGetMaxY(_zhanghuView.frame))];
    _s.pagingEnabled = YES;
    _s.delegate = self;
    _s.contentSize = CGSizeMake(_s.frame.size.width*2, 0);
    
    MingXiTab *duobiTab = [[MingXiTab alloc]initWithFrame:CGRectMake(0, 0, WYMWITH, _s.frame.size.height) AndType:DUOBI];
    MingXiTab *jifenTab = [[MingXiTab alloc]initWithFrame:CGRectMake(_s.frame.size.width, 0, WYMWITH, _s.frame.size.height) AndType:JIFEN];
    [_s addSubview:duobiTab];
    [_s addSubview:jifenTab];
    [self.view addSubview:_s];
}
//加载导航条
- (void)loadCustomNaviBar
{
    UIView *naviBar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WYMWITH, 20+44)];
    naviBar.backgroundColor = QBB_RED_COLOR;
    //返回按钮
    PublicBackBtn *backBtn = [[PublicBackBtn alloc]initWithVC:self andBackType:pop Img:[UIImage imageNamed:@"icon_back_white_press"]];
    [naviBar addSubview:backBtn];
    //标题
    UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 25)];
    titleLab.center = CGPointMake(WYMWITH/2, 42);
    titleLab.text = @"账户明细";
    titleLab.font = [UIFont systemFontOfSize:TITLE_SIZE];
    titleLab.textAlignment = NSTextAlignmentCenter;
    titleLab.textColor = [UIColor whiteColor];
    //分割线
    UILabel *fenge = [[UILabel alloc]initWithFrame:CGRectMake(0, 63.5, WYMWITH, 0.5)];
    fenge.backgroundColor = [UIColor lightGrayColor];
    [naviBar addSubview:fenge];
    [naviBar addSubview:titleLab];
    [self.view addSubview:naviBar];
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    NSInteger index = _s.contentOffset.x/WYMWITH;
    [_zhanghuView changeselectWithIndex:index];
}
- (void)changeOffsetWithIndex:(NSInteger)index
{
    [UIView animateWithDuration:0.2 animations:^{
        _s.contentOffset = CGPointMake(WYMWITH*index, 0);
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
